package interview;

public class interview_05_01 {
    public int insertBits(int N, int M, int i, int j) {
        int count=0;
        int n1=N;
        int right=0;
        for(int k=0;k<i;++k){
            right+=(n1 & 1) << count;
            n1=n1>>1;
            count++;
        }
        n1=N;
        n1=n1>>j>>1;
        n1=n1<<j<<1;
        int m=M<< i;
        n1=n1&m;
        n1=n1&right;
        return n1;
    }
}
